package com.wuye.repository;

import com.wuye.model.option.Questionnaire;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

/**
 * Created by jiawenlong on 2016/8/2.
 */
public interface QuestionnaireRepository extends PagingAndSortingRepository<Questionnaire,Long>{

    @Query(nativeQuery = true,value = "select * from Questionnaire where publishTime>=?1 and publishTime<= ?2 order by id desc ")
    List<Questionnaire> queryQuestionnaires(String dVal, String dVal2);
    @Query(nativeQuery = true,value = "select count(*) from Questionnaire where formId=? ")
    int queryQuestionnairesCountByFormId(long formId);

    @Query(nativeQuery = true,value = "select * from Questionnaire where state < 2")
    List<Questionnaire> findUnFinished();


}
